package com.kkb.factory2;

public class Factory2 {
//提供接口Car的实现类对象
    public static Car getCarInstance(String str){
        Car car = null;
        if ("Benz".equals(str)){
            car = new Benz();
        }else if("Bmw".equals(str)){
            car = new Bmw();
        }else if("QQ".equals(str)){
            car = new QQ();
        }
        return car;
//Class.forName(包名.类名).newInstance();
    }
}
